﻿#pragma once

#include "common.h"
#include "ui/controls.h"
#include "editor/settings.h"
#include "seqbase/store.h"
#include "tool.h"

namespace anip
{
	namespace editor
	{

		class DrawingArea : public EditorWindow
		{
		private:
			RenderBuffer* _buffer;
			vg::VgFrameGroup* _currentVfg;
			GraphicsRenderer* _vfgRenderer;

			Transform2D _dragStartTransform;
			vec2 _dragStart;
			bool _specialDrag = false;
			
			GraphicsRenderContext _cxt;

			ui::Draggable<ui::Panel>* _panel = nullptr;

		protected:
			void _scroll(invec2 pos);
			void _mouseMove(invec2 pos);
			void _mouseButton(MouseButton btn, ButtonAction action);
			bool _canBeginDrag(MouseButton btn, invec2 pos);
			void _processDrag(invec2 start, invec2 pos);
			void _endDrag();

			void _render();

		public:
			DrawingArea(Container* parent, SFrameGroup& fg);

			vg::VgFrameGroup& currentFrameGroup() { return *_currentVfg; }
			void updateRender();

			void setSize(invec2 size) override;

			void paint() override;
		};
	}
}